package com.guiji.quartz.formatter;

import cn.hutool.core.date.DateUtil;
import us.codecraft.webmagic.model.formatter.ObjectFormatter;

import java.util.Date;

/**
 * @program: cms-vue-plus
 * @description:
 * @author: gaoX
 * @create: 2021-08-26 11:36
 **/
public class DataFormatter implements ObjectFormatter<Date> {
	@Override
	public Date format(String s) {
		s=s.trim();
		Date date = DateUtil.date().toJdkDate();
		try {
			date = DateUtil.parse(s).toJdkDate();
		}catch (Exception e){
			System.out.println("s = " + s);
			e.printStackTrace();
		}
		return date;
	}

	@Override
	public Class<Date> clazz() {
		return Date.class;
	}

	@Override
	public void initParam(String[] strings) {
		// nothing
	}
}
